Add GitHub Actions workflow for Xcode build and analyze#1
Add GitHub Actions workflow for Xcode build and analyze#1wvnr5m6h4r-commits wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughChangesXcode CI workflow
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant GitHubActions
participant xcodebuild
participant xcpretty
GitHubActions->>xcodebuild: List projects and schemes
xcodebuild-->>GitHubActions: Return project metadata
GitHubActions->>xcodebuild: Run clean build analyze
xcodebuild->>xcpretty: Pipe build output
xcpretty-->>GitHubActions: Return pipeline status
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
.github/workflows/objective-c-xcode.yml (2)
15-16: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winSet
persist-credentials: falseon the checkout step.
actions/checkout@v4persists theGITHUB_TOKENin.git/configby default. Since this workflow only builds and analyzes—no pushes or commits—retaining credentials is an unnecessary exposure surface. Disable it explicitly.🔒️ Proposed fix
- name: Checkout uses: actions/checkout@v4 + with: + persist-credentials: false🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/objective-c-xcode.yml around lines 15 - 16, Update the checkout step using actions/checkout@v4 to set persist-credentials: false, ensuring the workflow does not retain the GITHUB_TOKEN in the repository configuration.Source: Linters/SAST tools
25-25: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify the obfuscated
schemeenv value.
${{ 'default' }}always evaluates to the literal stringdefault. This is unnecessarily indirect and obscures intent. Use a plain string.♻️ Proposed fix
- name: Build env: - scheme: ${{ 'default' }} + scheme: default🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/objective-c-xcode.yml at line 25, Replace the indirect expression assigned to the workflow’s scheme setting with the plain string value default, preserving the existing behavior while making the intent explicit.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/objective-c-xcode.yml:
- Around line 17-22: In the “Set Default Scheme” step, quote the shell
expansions for scheme_list and default to prevent word splitting, and replace
the piped echo/cat file write with a direct, appropriately quoted write to the
default file. Preserve the existing scheme parsing and log output.
- Around line 27-30: In the workflow’s scheme and build-file selection logic,
quote all variable expansions, especially in the `if` test and `file_to_build`
handling, to preserve paths containing spaces. Replace the dense
workspace/project detection command with clear, readable logic that explicitly
selects the intended `.xcworkspace` or `.xcodeproj` and fails when multiple or
no matches exist; update the `xcodebuild` invocation to use the quoted
variables.
---
Nitpick comments:
In @.github/workflows/objective-c-xcode.yml:
- Around line 15-16: Update the checkout step using actions/checkout@v4 to set
persist-credentials: false, ensuring the workflow does not retain the
GITHUB_TOKEN in the repository configuration.
- Line 25: Replace the indirect expression assigned to the workflow’s scheme
setting with the plain string value default, preserving the existing behavior
while making the intent explicit.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 32e6297f-e329-466d-8a47-b5d21d16c215
📒 Files selected for processing (1)
.github/workflows/objective-c-xcode.yml
| if [ $scheme = default ]; then scheme=$(cat default); fi | ||
| if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi | ||
| file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` | ||
| xcodebuild clean build analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Quote variables and simplify the workspace/project detection.
$scheme and $file_to_build are unquoted, risking word-splitting on paths with spaces. The one-liner on line 28 is hard to parse and will silently pick the first match if multiple .xcworkspace or .xcodeproj files exist.
🛡️ Proposed fix
run: |
- if [ $scheme = default ]; then scheme=$(cat default); fi
- if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi
- file_to_build=`echo $file_to_build | awk '{$1=$1;print}'`
- xcodebuild clean build analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]}
+ if [ "$scheme" = "default" ]; then scheme=$(cat default); fi
+ if [ -n "$(ls -A | grep -i '\.xcworkspace$')" ]; then
+ filetype_parameter="workspace"
+ file_to_build="$(ls -A | grep -i '\.xcworkspace$' | head -1)"
+ else
+ filetype_parameter="project"
+ file_to_build="$(ls -A | grep -i '\.xcodeproj$' | head -1)"
+ fi
+ file_to_build="$(echo "$file_to_build" | awk '{$1=$1;print}')"
+ xcodebuild clean build analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if [ $scheme = default ]; then scheme=$(cat default); fi | |
| if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi | |
| file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` | |
| xcodebuild clean build analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]} | |
| if [ "$scheme" = "default" ]; then scheme=$(cat default); fi | |
| if [ -n "$(ls -A | grep -i '\.xcworkspace$')" ]; then | |
| filetype_parameter="workspace" | |
| file_to_build="$(ls -A | grep -i '\.xcworkspace$' | head -1)" | |
| else | |
| filetype_parameter="project" | |
| file_to_build="$(ls -A | grep -i '\.xcodeproj$' | head -1)" | |
| fi | |
| file_to_build="$(echo "$file_to_build" | awk '{$1=$1;print}')" | |
| xcodebuild clean build analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]} |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/objective-c-xcode.yml around lines 27 - 30, In the
workflow’s scheme and build-file selection logic, quote all variable expansions,
especially in the `if` test and `file_to_build` handling, to preserve paths
containing spaces. Replace the dense workspace/project detection command with
clear, readable logic that explicitly selects the intended `.xcworkspace` or
`.xcodeproj` and fails when multiple or no matches exist; update the
`xcodebuild` invocation to use the quoted variables.
CMakeLists.txt
Summary by CodeRabbit